<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="message"><button onclick="send_msg()">发送消息</button>
<div id="chat_list">

</div>
</body>
<script type="application/javascript">
    var ws = new WebSocket("ws://127.0.0.1:9527/ws");

    ws.onmessage = function (eventMessage) {
        console.log(eventMessage.data);
        var p = document.createElement("p");
        p.innerText = eventMessage.data;
        document.getElementById("chat_list").appendChild(p);
        // var data_obj = JSON.parse(eventMessage.data);
        // console.log(data_obj);
    };

    function send_msg() {
        var msg = document.getElementById("message").value;
        ws.send(msg);
    }

</script>
</html>